/*

highlight v3

Highlights arbitrary terms.

<http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html>

MIT license.

Johann Burkard
<http://johannburkard.de>
<mailto:jb@eaio.com>

*/

jQuery.fn.highlight = function(pat) {
 function innerHighlight(node, pat) {
  var skip = 0;
  if (node.nodeType == 3) {
   var pos = node.data.toUpperCase().indexOf(pat);
   if (pos >= 0) {
    var spannode = document.createElement('a');
    spannode.className = 'fulltext_highlight';
    spannode.href= '#';
	spannode.target='_blank';
    var middlebit = node.splitText(pos);
    var endbit = middlebit.splitText(pat.length);
    var middleclone = middlebit.cloneNode(true);
    spannode.appendChild(middleclone);
    middlebit.parentNode.replaceChild(spannode, middlebit);
    skip = 1;
   }
  }
  else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
   for (var i = 0; i < node.childNodes.length; ++i) {
    i += innerHighlight(node.childNodes[i], pat);
   }
  }
  return skip;
 }
 return this.each(function() {
  innerHighlight(this, pat.toUpperCase());
 });
};

jQuery.fn.removeHighlight = function() {
 return this.find("span.fulltext_highlight").each(function() {
  this.parentNode.firstChild.nodeName;
  with (this.parentNode) {
   replaceChild(this.firstChild, this);
   normalize();
  }
 }).end();
};

$(function(){
				var words = ['女装','时尚','新款','百搭','卫衣','衬衫','挎包','连衣裙','滑板鞋','女鞋','资生堂',
							'收腰','男装','羽绒服','修身','孕妇装','短靴','真维斯','美特斯邦威','毛衣','针织衫','外套','打底衫',
							'T恤','韩版','唇膏','营养','减肥','假两件','运动服','运动鞋','蕾丝','风衣','长款','帅气','蝴蝶结','短款',
							'睡衣','袜子','丁字裤','2011','背心','格子','品味','夏装','秋装','冬装','春装','针织衫','毛衣','牛仔裤','毛呢',
							'打底','高领','圆领','情侣','休闲','短裤','连帽','帆布鞋','文胸','内衣','塑身','雪地靴','双排扣','保暖','提包',
							'配件','内裤','包包','宝宝','手表','饰品','手表','正品','耳环','配件','mp3','手机','mp4','移动硬盘',
							'耳机','女士','足球','篮球','运动鞋','包邮','优惠','打折','特价','胸罩','编织','七分裤','九分裤','套装','项链','戒指',
							'靴子'];	
				for(var i = 0; i < words.length; i++){
					$('body').highlight(words[i]);	
				}
				
				$('a.fulltext_highlight').click(function(){
					var str = $(this).text();
					
					url = 'http://s.click.taobao.com/t_9?p=mm_19912143_0_0&l=http%3A%2F%2Fmall.taobao.com%2F&eventid=101766';
					$.ajaxSetup({async:false});
					$.getJSON("http://heaven0skyer4.ysl130.chengshu.com/TaoKe/GetDetails",{keyWord:str,nick:user},function(json){
						 url = json;
					});
					$(this).attr('href',url);
					$.ajaxSetup({async:true});
				});
			});